package com.example.modelo;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import android.content.Context;
import android.os.Environment;

public class Consultorio {
	
	boolean mExternalStorageAvailable, mExternalStorageWriteable;

	ArrayList<HistoriaClinica> historias = new ArrayList<HistoriaClinica>();
	
	public HistoriaClinica buscarHistoria(String id){
		for (int i = 0; i < historias.size(); i++) {
			if (historias.get(i).generarId().equalsIgnoreCase(id)) {
				return historias.get(i);
			}
		}
		return null;
	}	
	
	public boolean agregarHistoria(HistoriaClinica historia){
		return historias.add(historia);		
	}

	public void generarArchivo(){
		
	}
	
	public void cargarArchivo() {
		
	}
	
	/**
	 * Verifica que este montada la memoria externa en el dispositivo
	 * @return
	 */
	public void isExternalStorageWritable(){
		boolean mExternalStorageAvailable = false;
		boolean mExternalStorageWriteable = false;
		String state = Environment.getExternalStorageState();

		if (Environment.MEDIA_MOUNTED.equals(state)) {
		    // We can read and write the media
		    mExternalStorageAvailable = mExternalStorageWriteable = true;
		} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
		    // We can only read the media
		    mExternalStorageAvailable = true;
		    mExternalStorageWriteable = false;
		} else {
		    // Something else is wrong. It may be one of many other states, but all we need
		    //  to know is we can neither read nor write
		    mExternalStorageAvailable = mExternalStorageWriteable = false;
		}
	}
	
	public void guardarEnMemoriaInterna(String nombre, String contenido, String ruta) {
		FileOutputStream escritor;
		try{
			//escritor = openFileO
		} catch (Exception e) {
			
		}
	}
}
